package com.socodethis.spaceex;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;

public class textureHolder {
	//this class is here to create return copies of all of the sprites.
	//prob should be implemented better and should always be called from the splash 
	//screen when the charClass function is loading
	texturePackerLoader tStructures, tSprites,tUtils;
	public textureHolder(){tStructures = new texturePackerLoader("data/structures_level_1.txt","data/structures_level_1.png",133);
	tSprites = new texturePackerLoader("data/sprites.txt","data/sprites.png",0);
	tUtils = new texturePackerLoader("data/utils.txt","data/utils.png",0);
	}
	public Sprite returnAttack(int attack){
		switch(attack){
			case 0:  return new Sprite(new Texture(Gdx.files.internal("player_attacks/fireball.png")));
			default: return new Sprite(new Texture(Gdx.files.internal("player_attacks/fireball.png")));
		}
	}
	public Sprite[] returnHealthBar(){
		Sprite[] bar = {new Sprite(new Texture(Gdx.files.internal("player_attacks/hbar_inner.png"))),
				new Sprite(new Texture(Gdx.files.internal("player_attacks/hbar_outer.png")))};
		return bar;
	}
	
	public Sprite[] returnUtilsArrows(){
		Sprite[] arrows = {new Sprite(tUtils.getName("Arrow")),new Sprite(tUtils.getName("Arrow")),new Sprite(tUtils.getName("Arrow")),new Sprite(tUtils.getName("Arrow"))};
		arrows[1].flip(false, true);
		arrows[2].flip(true, false);
		arrows[3].flip(true, true);
		return arrows;
	}
	
	public Sprite[] returnEnemyRobot_ld(boolean rotated){
		Sprite[] ld = {new Sprite(tSprites.getName("robot_ld1")),
						new Sprite(tSprites.getName("robot_ld2")),
						new Sprite(tSprites.getName("robot_ld3")),
						new Sprite(tSprites.getName("robot_ld4"))};
		if(rotated){
			for(Sprite sprite: ld){
				sprite.flip(true, false);
			}
		}
		return ld;
	}
	public Sprite[] returnEnemyRobot_lu(boolean rotated){
		Sprite[] lu = {new Sprite(tSprites.getName("robot_lu1")),
				new Sprite(tSprites.getName("robot_lu2")),
				new Sprite(tSprites.getName("robot_lu3")),
				new Sprite(tSprites.getName("robot_lu4"))};
		if(rotated){
			for(Sprite sprite: lu){
				sprite.flip(true, false);
			}
		}
		return lu;
	}
	
	public Sprite returnProgressBar(){
		return new Sprite(tUtils.getName("progress"));
	}
	
	public Sprite[] returnEnemyMech_ld(boolean rotated){
		Sprite[] ld = {new Sprite(tSprites.getName("mech_ld1"))};
		if(rotated){
			for(Sprite sprite: ld){
				sprite.flip(true, false);
			}
		}
		return ld;
	}
	public Sprite[] returnEnemyMech_lu(boolean rotated){
		Sprite[] lu = {new Sprite(tSprites.getName("mech_ld1"))};
		if(rotated){
			for(Sprite sprite: lu){
				sprite.flip(true, false);
			}
		}
		return lu;
	}
	
	public Sprite[] returnEnemyTank_ld(boolean rotated){
		Sprite[] ld = {new Sprite(tSprites.getName("tank_ld1"))};
		if(rotated){
			for(Sprite sprite: ld){
				sprite.flip(true, false);
			}
		}
		return ld;
	}
	public Sprite[] returnEnemyTank_lu(boolean rotated){
		Sprite[] lu = {new Sprite(tSprites.getName("tank_ld1"))};
		if(rotated){
			for(Sprite sprite: lu){
				sprite.flip(true, false);
			}
		}
		return lu;
	}
	
	
	public Sprite[] returnEnemySkull_ld(boolean rotated){
		Sprite[] ld = {new Sprite(tSprites.getName("skull_ld1")),
						new Sprite(tSprites.getName("skull_ld2")),
						new Sprite(tSprites.getName("skull_ld3")),
						new Sprite(tSprites.getName("skull_ld4")),
						new Sprite(tSprites.getName("skull_ld5"))};
		if(rotated){
			for(Sprite sprite: ld){
				sprite.flip(true, false);
			}
		}
		return ld;
	}
	public Sprite[] returnEnemySkull_lu(boolean rotated){
		Sprite[] lu = {new Sprite(tSprites.getName("skull_lu1")),
				new Sprite(tSprites.getName("skull_lu2")),
				new Sprite(tSprites.getName("skull_lu3")),
				new Sprite(tSprites.getName("skull_lu4")),
				new Sprite(tSprites.getName("skull_lu5"))};
		if(rotated){
			for(Sprite sprite: lu){
				sprite.flip(true, false);
			}
		}
		return lu;
	}
	
	public Sprite[] returnEnemySpider_ld(boolean rotated){
		Sprite[] ld = {new Sprite(tSprites.getName("spider_ld1")),
						new Sprite(tSprites.getName("spider_ld2")),
						new Sprite(tSprites.getName("spider_ld3"))};
		if(rotated){
			for(Sprite sprite: ld){
				sprite.flip(true, false);
			}
		}
		return ld;
	}
	public Sprite[] returnEnemySpider_lu(boolean rotated){
		Sprite[] lu = {new Sprite(tSprites.getName("spider_lu1")),
				new Sprite(tSprites.getName("spider_lu2")),
				new Sprite(tSprites.getName("spider_lu3"))};
		if(rotated){
			for(Sprite sprite: lu){
				sprite.flip(true, false);
			}
		}
		return lu;
	}
	
	public Sprite[] returnPlayer_ld(boolean rotated){
		Sprite[] ld = {new Sprite(tSprites.getName("catani_ld1")),
				new Sprite(tSprites.getName("catani_ld2")),
				new Sprite(tSprites.getName("catani_ld3"))};
		if(rotated){
			for(Sprite sprite: ld){
				sprite.flip(true, false);
			}
		}
		return ld;
	}
	
	public Sprite[] returnPlayer_lu(boolean rotated){
		Sprite[] lu = {new Sprite(tSprites.getName("catani_lu1")),
				new Sprite(tSprites.getName("catani_lu2")),
				new Sprite(tSprites.getName("catani_lu3"))};
		if(rotated){
			for(Sprite sprite: lu){
				sprite.flip(true, false);
			}
		}
		return lu;
	}
	
	public Sprite[] returnStatue(){
		Sprite[] statue = {new Sprite(tStructures.getName("pole2"))};
		return statue;
	}
	public Sprite backGround(int index){
		switch(index){
			case 0: return new Sprite(new Texture(Gdx.files.internal("test_skybox.png")));
			default: return new Sprite(new Texture(Gdx.files.internal("test_skybox.png")));
		}
	}
	public Sprite returnDoor(int index){
		switch(index){
		case 0: return new Sprite(new Texture(Gdx.files.internal("structures/structure_doorO.png")));
		case 1: return new Sprite(new Texture(Gdx.files.internal("structures/structure_doorC.png")));
		default: return new Sprite(new Texture(Gdx.files.internal("structures/structure_test.png")));
	}
	}
	public Sprite returnButton(int index){
		switch(index){
		case 0: return new Sprite(new Texture(Gdx.files.internal("structures/structure_buttonOn.png")));
		case 1: return new Sprite(new Texture(Gdx.files.internal("structures/structure_buttonOff.png")));
		default: return new Sprite(new Texture(Gdx.files.internal("structures/structure_test.png")));
	}
	}
	public Sprite returnStructure(int index){
		switch(index){
		case 0: return new Sprite(new Texture(Gdx.files.internal("structures/structure_test.png")));
		case 1: return new Sprite(new Texture(Gdx.files.internal("structures/structure_test2.png")));
		case 2: return new Sprite(new Texture(Gdx.files.internal("structures/structure_test3.png")));
		case 3: return new Sprite(new Texture(Gdx.files.internal("structures/structure_test4.png")));
		default: return new Sprite(new Texture(Gdx.files.internal("structures/structure_test.png")));
	}
	}
	
}
